package com.syf.kit.enums;

import cn.hutool.core.util.StrUtil;

public enum DataSourceType {
    // 默认为单个
    SINGLE("single"),
    MULTIPLE("multiple"),
    RW("read-write");

    private String name;

    DataSourceType(String name) {
        this.name = name;
    }

    public String getTypeName() {
        return name;
    }

    public static DataSourceType getDsTypeByName(String dsTypeName) {
        for (DataSourceType dataSourceType : DataSourceType.values()) {
            if (StrUtil.equals(dataSourceType.getTypeName(), dsTypeName)) {
                return dataSourceType;
            }
        }

        return null;
    }

    public static String getAllNameString() {
        StringBuilder sb = new StringBuilder();
        for (DataSourceType dataSourceType : DataSourceType.values()) {
            sb.append(",").append(dataSourceType.getTypeName());
        }

        return sb.substring(1);
    }

    public String getName() {
        return name;
    }
}
